package com.thxy.jxgl.mubiaoka.servlet;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.thxy.jxgl.bumen.manager.BumenManager;
import com.thxy.jxgl.filter.ToCh;
import com.thxy.jxgl.javaBean.BuMen;
import com.thxy.jxgl.javaBean.khxm;
import com.thxy.jxgl.mubiaoka.manager.MubiaokaManager;

public class MubiaokaServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String method = request.getParameter("method") == null?"":request.getParameter("method");
		request.setCharacterEncoding("gbk");
        if("addxiangmu".equals(method))
        {
            khxm xm=(khxm)request.getSession().getAttribute("xiangmu");
            request.getSession().removeAttribute("xiangmu");
            String xmname=ToCh.toChinese(xm.getXm_name());
            String xmno=xm.getXm_id();
        	//boolean ins=MubiaokaManager.getInstance().addXm(xmno, xmname);
        }else if ("xiugai".equals(method)) {
			
		}else if ("delexiangmu".equals(method)) {
			String xmno=request.getParameter("xmno");
			//MubiaokaManager.getInstance().deleXm(xmno);
		}else if ("delezhibiao".equals(method)) {
			String zbno=request.getParameter("zbno");
			MubiaokaManager.getInstance().deleZb(zbno);}
		else if ("editxiangmu".equals(method)) {
			String xmno=request.getParameter("xmno");
			String xmname=request.getParameter("xm_name").toString();
			//boolean upd=MubiaokaManager.getInstance().updateXm(xmname, xmno);
		}
        
		List xmList=new ArrayList();
		//xmList=MubiaokaManager.getInstance().getXiangmu();
		request.getSession().setAttribute("xmList",xmList );
		List zbList=new ArrayList();
		zbList=MubiaokaManager.getInstance().getZhibiao();
		request.setAttribute("zbList", zbList);
		request.getRequestDispatcher("/mbkgl/mubiaoka.jsp").forward(request, response);

		}
	
}
